package biz.datalk.industrialland.admin.modules.system.pojo.dto;

import biz.datalk.industrialland.common.pojo.po.BasePO;
import biz.datalk.industrialland.common.validated.BatchDelete;
import biz.datalk.industrialland.common.validated.Delete;
import biz.datalk.industrialland.common.validated.Insert;
import biz.datalk.industrialland.common.validated.Update;
import biz.datalk.industrialland.mbg.pojo.po.SysFunction;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author tarofang@163.com
 * @date 2019-09-09
 */
@Getter
@Setter
@ToString
public class SysFunctionDTO extends BasePO implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     * <p>
     * sys_function.id
     */
    @EqualsAndHashCode.Include
    @NotNull(groups = {Delete.class, Update.class}, message = "{validations.sys.function.no.exists.or.delete}")
    private Long id;

    /**
     * 父id
     * <p>
     * sys_function.pid
     */
    private Long pid;

    /**
     * 菜单编码
     * <p>
     * sys_function.func_code
     */
    private String funcCode;

    /**
     * 菜单标题
     * <p>
     * sys_function.title
     */
    @NotBlank(groups = {Insert.class, Update.class}, message = "validations.sys.function.invalid.blank.title")
    private String title;

    /**
     * 跳转路径
     * <p>
     * sys_function.url
     */
    // @NotBlank(groups = {Insert.class, Update.class}, message = "{validations.sys.function.invalid.blank.url}")
    private String url;

    /**
     * 菜单图标
     * <p>
     * sys_function.icon
     */
    // @NotNull(groups = {Insert.class, Update.class}, message = "{validations.sys.function.invalid.blank.icon}")
    private String icon;

    /**
     * 菜单类型(0:一级菜单; 1:子菜单:2:按钮权限)
     * <p>
     * sys_function.func_type
     */
    @NotNull(groups = {Insert.class, Update.class}, message = "{validations.sys.function.invalid.blank.funcType}")
    private Integer funcType;

    /**
     * 菜单权限编码
     * <p>
     * sys_function.perms
     */
    private String perms;

    /**
     * 权限策略1显示2禁用
     * <p>
     * sys_function.perms_type
     */
    private String permsType;

    /**
     * 菜单排序
     * <p>
     * sys_function.func_index
     */
    @NotNull(groups = {Insert.class, Update.class}, message = "{validations.sys.function.invalid.blank.funcIndex}")
    private Integer funcIndex;

    /**
     * 是否隐藏: 0否,1是
     * <p>
     * sys_function.hidden
     */
    private Integer hidden;

    /**
     * 描述
     * <p>
     * sys_function.description
     */
    private String description;

    /**
     * 状态（Y启用，N不启用）
     * <p>
     * sys_function.is_valid
     */
    private String isValid;

    /**
     * 删除状态（N，正常，Y已删除）
     * <p>
     * sys_function.is_delete
     */
    private String isDelete;

    /**
     * 创建人
     * <p>
     * sys_function.create_by
     */
    private transient Long createBy;

    /**
     * 创建时间
     * <p>
     * sys_function.create_time
     */
    private transient Date createTime;

    /**
     * 更新人
     * <p>
     * sys_function.update_by
     */
    private transient Long updateBy;

    /**
     * 更新时间
     * <p>
     * sys_function.update_time
     */
    private transient Date updateTime;

    @NotBlank(groups = BatchDelete.class, message = "validations.sys.function.no.exists.or.delete")
    private String sysids;

    private Boolean hasChildren;
    private List<SysFunctionDTO> children;

    public SysFunctionDTO() {
    }

    public SysFunctionDTO(SysFunction func) {
        this.setHasChildren(false);
        this.setChildren(new ArrayList<>());
        this.setId(func.getId());
        this.setPid(func.getPid());
        this.setFuncCode(func.getFuncCode());
        this.setTitle(func.getTitle());
        this.setUrl(func.getUrl());
        this.setIcon(func.getIcon());
        this.setFuncType(func.getFuncType());
        this.setPerms(func.getPerms());
        this.setPermsType(func.getPermsType());
        this.setFuncIndex(func.getFuncIndex());
        this.setHidden(func.getHidden());
        this.setDescription(func.getDescription());
        this.setIsValid(func.getIsValid());
        this.setIsDelete(func.getIsDelete());
        this.setCreateBy(func.getCreateBy());
        this.setCreateTime(func.getCreateTime());
        this.setUpdateBy(func.getUpdateBy());
        this.setUpdateTime(func.getUpdateTime());
    }
}
